#version 110
varying vec3 normal;
varying vec4 position;
varying vec2 TexCoord;
uniform sampler2D Tex1;
uniform vec3 LightIntensity; 
uniform vec4 LightPosition;		// Light position in eye coords;



uniform vec3 Ka;				// Ambient reflectivity
uniform vec3 Kd;				// Diffuse reflectivity
uniform vec3 Ks;				// Specular reflectivity
uniform float Shininess;	

vec3 ads( )
{
vec3 n = normalize( normal );
vec3 s = normalize( vec3(LightPosition) - vec3(position) );
vec3 v = normalize(vec3(-position));
vec3 r = reflect( -s, n );
return
LightIntensity *
( Ka +
Kd * max( dot(s, n), 0.0 ) +
Ks * pow( max( dot(r,v), 0.0 ), Shininess ) );
}

void main()
{
	vec4 texColor = texture2D( Tex1, TexCoord );
	gl_FragColor = texColor * vec4(ads(), 1.0);
}